<template>
	<el-tabs type="card" style="text-align:left;background-color:#eeeeee;">
  		<el-tab-pane label="修改组合">
  			<el-row>
  				<el-col :span="7">
  					<label>请选择主诉：</label>
 					<el-select v-model="curComplaint" placeholder="请选择" value-key="complaintId" @change="changeComplaint">
    					<el-option-group
      						v-for="system in systems"
      						:key="system.systemCode"
      						:label="system.systemName">
      						<el-option
        						v-for="complaint in system.complaintList"
      							:key="complaint.complaintId"
      							:label="complaint.complaintName"
      							:value="complaint">
      						</el-option>
    					</el-option-group>
  					</el-select>
  				</el-col>
  				<el-col :span="6">
  					<label>请选择疾病：</label>
  					<el-select v-model="curDisease" placeholder="请选择" value-key="diseaseCode" @change="changeDisease">
    					<el-option
      						v-for="disease in diseases"
      						:key="disease.diseaseCode"
      						:label="disease.diseaseName"
      						:value="disease">
    					</el-option>
 					</el-select>
  				</el-col>
  				<!-- <el-col :span="5">
  					<el-button @click="AddDiseaseGroup()">添加新疾病组合</el-button>
  				</el-col> -->
  			</el-row>
  			<el-row style="margin-top:30px;margin-left:10px;">
  				<el-col :span="15" v-if="curDisease" >
  					<el-row class="panel shortPanel">
  						<el-col :span="12">
  							<label>【{{curDisease.diseaseName}}】最短组合</label>
  						</el-col>
  						<el-col :span="12" style="text-align:right" v-if="curDisease.diseaseName">
  							<el-button size="mini" @click="handleAdd('S')">添加最短组合</el-button>
  						</el-col>
  						<el-col>
							<el-table
							    :data="diseaseSGroups"
							    stripe
    							border
							    style="width: 100%">
							    <el-table-column
							      label="组合ID"
							      width="80">
							      <template slot-scope="scope">
							        <span style="margin-left: 10px">{{ scope.row.groupId }}</span>
							      </template>
							    </el-table-column>
							    <el-table-column
							      label="组合内容">
							      <template slot-scope="scope">
							      	<span style="margin-left: 10px">{{ scope.row.groupContent}}</span>
							      </template>
							    </el-table-column>
							    <el-table-column label="操作" width="280">
							      <template slot-scope="scope">
							        <el-button
							          size="mini"
							          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
							        <el-button
							          size="mini"
							          @click="handleJieXi(scope.$index, scope.row)">解析</el-button>
							        <el-button
							          size="mini"
							          type="danger"
							          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
							      </template>
							    </el-table-column>
							 </el-table>
  						</el-col>
  					</el-row>
  					<el-row class="panel longPanel">
  						<el-col :span="12">
  							<label>【{{curDisease.diseaseName}}】最长组合</label>
  						</el-col>
  						<el-col :span="12" style="text-align:right" v-if="curDisease.diseaseName">
  							<el-button size="mini" @click="handleAdd('L')">添加最长组合</el-button>
  						</el-col>
  						<el-col :span="24">
  							<el-table
							    :data="diseaseLGroups"
							    stripe
    							border
							    style="width: 100%">
							    <el-table-column
							      label="组合ID"
							      width="80">
							      <template slot-scope="scope">
							        <span style="margin-left: 10px">{{ scope.row.groupId }}</span>
							      </template>
							    </el-table-column>
							    <el-table-column
							      label="组合内容">
							      <template slot-scope="scope">
							      	<span style="margin-left: 10px">{{ scope.row.groupContent}}</span>
							      </template>
							    </el-table-column>
							    <el-table-column label="操作" width="280">
							      <template slot-scope="scope">
							        <el-button
							          size="mini"
							          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
							        <el-button
							          size="mini"
							          @click="handleJieXi(scope.$index, scope.row)">解析</el-button>
							        <el-button
							          size="mini"
							          type="danger"
							          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
							      </template>
							    </el-table-column>
							 </el-table>
  						</el-col>
  					</el-row>
  					<el-dialog
					  title="编辑组合"
					  :visible.sync="dialogVisible"
					  width="30%">
					  <el-row>
					  	<el-col></el-col>
					  	<el-col><el-input v-model="newGroupContent" placeholder="请输入内容"></el-input></el-col>
					  </el-row>
					  <span slot="footer" class="dialog-footer">
					    <el-button @click="dialogVisible = false">取 消</el-button>
					    <el-button type="primary" @click="confirmEditGroup">确 定</el-button>
					  </span>
					</el-dialog>
					<el-dialog
					  title="添加组合"
					  :visible.sync="addDialog"
					  width="30%">
					  <el-row>
					  	<el-col>
					  		<span v-if="curGroup.groupType=='L'">请规范填写最长组合内容</span>
					  		<span v-if="curGroup.groupType=='S'">请规范填写最短组合内容</span>
					  	</el-col>
					  	<el-col><el-input v-model="addGroupContent" placeholder="请输入内容"></el-input></el-col>
					  </el-row>
					  <span slot="footer" class="dialog-footer">
					    <el-button @click="addDialog = false">取 消</el-button>
					    <el-button type="primary" @click="confirmAddGroup">确 定</el-button>
					  </span>
					</el-dialog>
  					<el-row class="panel symptomPanel">
  						<el-col>
  							<label>可选症状列表</label>
  						</el-col>
  						<el-col>
  							<el-table
    							:data="allSymptoms"
    							stripe
    							border
    							style="width: 100%">
							    <el-table-column
							      prop="symptomCode"
							      label="症状编号"
							      width="100">
							    </el-table-column>
							    <el-table-column
							      prop="symptomName"
							      label="症状描述">
							    </el-table-column>
							</el-table>
  						</el-col>
  					</el-row>
  				</el-col>
  				<el-col :span="8" class="panel jiexiPanel">
  					<el-row>
  						<el-col>
  							<label>解析内容(字母内容暂时无法解析){{curGroup.groupId}}</label>
  						</el-col>
  						<el-col>
  							<el-table
    							:data="jiexiSymptoms"
    							stripe
    							border
    							style="width: 100%">
							    <el-table-column
							      prop="symptomCode"
							      label="症状编号"
							      width="100">
							    </el-table-column>
							    <el-table-column
							      prop="symptomName"
							      label="症状描述">
							    </el-table-column>
							</el-table>
  						</el-col>
  					</el-row>
  				</el-col>
  			</el-row>
  		</el-tab-pane>
  		<el-tab-pane label="修改症状">
  			<el-row>
  				<el-col :span="8">
  					<label>请选择主诉：</label>
 					<el-select v-model="curComplaint" placeholder="请选择" value-key="complaintId" @change="changeComplaint">
    					<el-option-group
      						v-for="system in systems"
      						:key="system.systemCode"
      						:label="system.systemName">
      						<el-option
        						v-for="complaint in system.complaintList"
      							:key="complaint.complaintId"
      							:label="complaint.complaintName"
      							:value="complaint">
      						</el-option>
    					</el-option-group>
  					</el-select>
  				</el-col>
  			</el-row>
  			<el-row class="symptomPanel">
  				<el-col :span="12">当前主诉下的症状列表</el-col>
  				<el-col :span="12" style="text-align:right" v-if="curComplaint.complaintName">
  					<el-button size="mini" @click="symptomAdd()">添加症状</el-button>
  				</el-col>
  				<el-col>
  					<el-table
					    :data="allSymptoms"
					    stripe
						border
					    style="width: 100%">
					    <el-table-column
					      label="症状编号"
					      width="120">
					      <template slot-scope="scope">
					        <span style="margin-left: 10px">{{ scope.row.symptomCode }}</span>
					      </template>
					    </el-table-column>
					    <el-table-column
					      label="症状内容">
					      <template slot-scope="scope">
					      	<span style="margin-left: 10px">{{ scope.row.symptomName}}</span>
					      </template>
					    </el-table-column>
					    <el-table-column
					      label="症状排序号"
					      width="120">
					      <template slot-scope="scope">
					      	<span style="margin-left: 10px">{{ scope.row.symptomIndex}}</span>
					      </template>
					    </el-table-column>
					    <el-table-column label="操作" width="400">
					      <template slot-scope="scope">
					        <el-button
					          size="mini"
					          @click="symptomEdit(scope.$index, scope.row)">编辑</el-button>
					        <el-button
					          size="mini"
					          @click="symptomUp(scope.$index, scope.row)">上移</el-button>
					          <el-button
					          size="mini"
					          @click="symptomDown(scope.$index, scope.row)">下移</el-button>
					        <el-button
					          size="mini"
					          type="danger"
					          @click="symptomDelete(scope.$index, scope.row)">删除</el-button>
					      </template>
					    </el-table-column>
					 </el-table>
  				</el-col>
  			</el-row>
  			<el-dialog
				  title="编辑症状"
				  :visible.sync="editSymptomDialog"
				  width="30%">
				  <el-row>
				  	<el-col><el-input v-model="newSymptomName" placeholder="请输入内容"></el-input></el-col>
				  </el-row>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="editSymptomDialog = false">取 消</el-button>
				    <el-button type="primary" @click="confirmEditSymptom">确 定</el-button>
				  </span>
			</el-dialog>
			<el-dialog
				  title="添加新症状"
				  :visible.sync="addSymptomDialog"
				  width="40%">
				  <el-row>
				  	<el-col>
				  		<span>请规范填写症状内容(默认在首位)</span>
				  	</el-col>
				  	<el-col><label>症状编号:</label></el-col>
				  	<el-col><el-input v-model="addSymptomCode" placeholder="请输入编号"></el-input></el-col>
				  	<el-col><label>症状内容:</label></el-col>
				  	<el-col><el-input v-model="addSymptomName" placeholder="请输入内容"></el-input></el-col>
				  </el-row>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="addSymptomDialog = false">取 消</el-button>
				    <el-button type="primary" @click="confirmAddSymptom">确 定</el-button>
				  </span>
			</el-dialog>
  		</el-tab-pane>
  		<el-tab-pane label="修改疾病">
  			<el-row>
  				<el-col :span="8">
  					<label>请选择主诉：</label>
 					<el-select v-model="curComplaint" placeholder="请选择" value-key="complaintId" @change="changeComplaint">
    					<el-option-group
      						v-for="system in systems"
      						:key="system.systemCode"
      						:label="system.systemName">
      						<el-option
        						v-for="complaint in system.complaintList"
      							:key="complaint.complaintId"
      							:label="complaint.complaintName"
      							:value="complaint">
      						</el-option>
    					</el-option-group>
  					</el-select>
  				</el-col>
  			</el-row
  			<el-row>
  				<el-col :span="13">
  					<el-row>
  						<!-- <el-col style="text-align:right">
  								<el-button size="mini" @click="diseaseAdd">添加新疾病</el-button>
  						</el-col> -->
  						<el-col>
  							<el-table
							    :data="diseases"
							    stripe
								border
							    style="width: 100%">
							    <el-table-column
							      label="编号"
							      width="50">
							      <template slot-scope="scope">
							        <span style="margin-left: 10px">{{ scope.row.diseaseCode }}</span>
							      </template>
							    </el-table-column>
							    <el-table-column
							      label="疾病名称"
							      width="150">
							      <template slot-scope="scope">
							      	<span style="margin-left: 10px">{{ scope.row.diseaseName}}</span>
							      </template>
							    </el-table-column>
							    <el-table-column
							      label="处置集合"
							      >
							      <template slot-scope="scope">
							      	<span style="margin-left: 10px">{{ scope.row.diseaseDisposalCodes}}</span>
							      </template>
							    </el-table-column>
							    <el-table-column label="操作" width="160">
							      <template slot-scope="scope">
							        <el-button
							          size="mini"
							          @click="diseaseEdit(scope.$index, scope.row)">编辑</el-button>
							        <el-button
							          size="mini"
							          @click="diseaseJieXi(scope.$index, scope.row)">解析</el-button>
							        <!-- <el-button
							          size="mini"
							          type="danger"
							          @click="diseaseDelete(scope.$index, scope.row)">删除</el-button> -->
							      </template>
							    </el-table-column>
							 </el-table>
  						</el-col>
  					</el-row>	
  				</el-col>
  				<el-col :span="10" style="margin-left:10px;">
  					<el-col>疾病处置内容解析：{{curDisease.diseaseCode}}</el-col>
  					<el-col>
  						<el-table
							:data="disposals"
							stripe
							border
							style="width: 100%">
						    <el-table-column
						      prop="disposalCode"
						      label="处置编号"
						      width="100">
						    </el-table-column>
						    <el-table-column
						      prop="disposalContent"
						      label="处置内容">
						    </el-table-column>
						</el-table>
  					</el-col>
  				</el-col>
  			</el-row>
  			<el-dialog
				  title="编辑疾病"
				  :visible.sync="editDiseaseDialog"
				  width="60%">
				  <el-row>
				  	<el-col>疾病名称：</el-col>
				  	<el-col><el-input v-model="newDiseaseName" placeholder="请输入内容"></el-input></el-col>
				  	<el-col>处置组合[此处末尾不要加逗号]：</el-col>
				  	<el-col><el-input v-model="newDiseaseDisposalCodes" placeholder="请输入内容"></el-input></el-col>
				  </el-row>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="editDiseaseDialog = false">取 消</el-button>
				    <el-button type="primary" @click="confirmEditDisease">确 定</el-button>
				  </span>
			</el-dialog>
			<el-dialog
				  title="添加新疾病"
				  :visible.sync="addDiseaseDialog"
				  width="40%">
				  <el-row>
				  	<el-col>
				  		<span>请规范填写症状内容(默认在首位)</span>
				  	</el-col>
				  	<el-col><label>疾病编号:</label></el-col>
				  	<el-col><el-input v-model="addDiseaseCode" placeholder="请输入编号"></el-input></el-col>
				  	<el-col><label>疾病名称:</label></el-col>
				  	<el-col><el-input v-model="addDiseaseName" placeholder="请输入内容"></el-input></el-col>
				  	<el-col><label>处置集合:</label></el-col>
				  	<el-col><el-input v-model="addDiseaseDisposalCodes" placeholder="请输入内容"></el-input></el-col>
				  </el-row>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="addDiseaseDialog = false">取 消</el-button>
				    <el-button type="primary" @click="confirmAddDisease">确 定</el-button>
				  </span>
			</el-dialog>
  		</el-tab-pane>
  		<el-tab-pane label="修改处置">修改处置</el-tab-pane>
	</el-tabs>
</template>
<script type="text/javascript">
	export default{
		name:'ManagePanel',
		data(){
			return {
				curComplaint: {},
				systems: [],
				curDisease: {},
				curGroup:{},
				curSymptom:{},
				diseases:[],
				allSymptoms:[],
				diseaseSGroups:[],
				diseaseLGroups:[],
				jiexiSymptoms:[],
				dialogVisible:false,
				newGroupContent: '',
				addGroupContent: '',
				addDialog: false,
				editSymptomDialog:false,
				addSymptomDialog:false,
				addSymptomName:'',
				addSymptomCode:'',
				editDiseaseDialog:false,
				addDiseaseDialog:false,
				addDiseaseName:'',
				addDiseaseCode:'',
				addDiseaseDisposalCodes:'',
				newDiseaseName:'',
				newDiseaseDisposalCodes:'',
				newSymptomName:'',
				disposals:[]
			}
		}, 
		methods:{
			changeComplaint:function(){
				this.curDisease = {};
				this.allSymptoms =[];
				this.diseaseSGroups = [];
				this.diseaseLGroups = [];
				this.jiexiSymptoms = [];
				var curComplaint = this.curComplaint;
				var vm = this;
				$.ajax({
                    type:"get",
                    url:CONST.url+"getDiseaseByComplaint",
                    data:{"complaintCode": curComplaint.complaintCode},
                    success:function(result){
                        if (result.code==0||result.code=='0') {
                        	vm.diseases = result.data;
                        }else{
                        	alert("主诉数据请求失败！");
                        }
                    },
                    error:function(){
                    	alert("主诉数据请求失败！");
                    }
                });
                $.ajax({
					type:"get",
					url:CONST.url+"getComplaintByCode",
					data:{"complaintCode": curComplaint.complaintCode},
					success:function(result){
						if (result.code==0||result.code=='0') {
							vm.allSymptoms = result.data.symptomList;
						}else{
							alert("主诉数据请求失败！");
						}
					},
					error:function(){
						alert("主诉数据请求失败！");
					}
				})
			},
			changeDisease:function(){
				this.jiexiSymptoms = [];
				var vm = this;
				$.ajax({
					type:"post",
					url:CONST.url+"queryByDisease",
					data:{"diseaseCode": vm.curDisease.diseaseCode},
					success:function(result){
						if (result.code==0||result.code=='0') {
							vm.diseaseLGroups = result.data.diseaseLGroups;
							vm.diseaseSGroups = result.data.diseaseSGroups;
						}else{
							alert("组合获取失败！");
						}
					},
					error:function(){
						alert("组合获取失败！");
					}
				})
			},
			handleEdit:function(index,row){
				this.curGroup = row;
				this.dialogVisible = true;
				this.newGroupContent = row.groupContent;

			},
			handleDelete:function(index,row){
				var vm = this;
				 this.$confirm('建议点击【取消】后使用编辑功能备注删除，若仍坚持删除，请点击【确定】')
		          .then(_ => {
		            //执行删除功能
		            $.ajax({
					type:"post",
					url:CONST.url+"deleteGroupById",
					data:{
						"groupId": row.groupId
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							$.ajax({
								type:"post",
								url:CONST.url+"queryByDisease",
								data:{"diseaseCode": vm.curDisease.diseaseCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.diseaseLGroups = result.data.diseaseLGroups;
										vm.diseaseSGroups = result.data.diseaseSGroups;
									}else{
										alert("组合获取失败！");
									}
								},
								error:function(){
									alert("组合获取失败！");
								}
							});
						}else{
							alert("解析失败！");
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
		          })
		          .catch(_ => {});
			},
			handleJieXi:function(index,row){
				this.curGroup = row;
				var vm = this;
				$.ajax({
					type:"post",
					url:CONST.url+"querySymptomByCodes",
					data:{"groupContent": row.groupContent},
					success:function(result){
						if (result.code==0||result.code=='0') {
							vm.jiexiSymptoms = result.data;
						}else{
							alert("解析失败！");
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
			},
			AddDiseaseGroup:function(){

			},
			confirmEditGroup:function(){
				var newGroupContent = this.newGroupContent;
				var vm = this;
				if (newGroupContent=="") {
					alert("组合内容不能为空");
					return;
				}
				if (newGroupContent.charAt(newGroupContent.length-1)!=',') {
					alert("不符合规范，末尾请加入英文逗号");
					return;
				}
				//过滤中文逗号
				 newGroupContent = newGroupContent.replace(new RegExp('，',"gm"),',');
				 $.ajax({
					type:"post",
					url:CONST.url+"updateGroupById",
					data:{
						"groupContent": newGroupContent,
						"groupId": vm.curGroup.groupId
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							$.ajax({
								type:"post",
								url:CONST.url+"queryByDisease",
								data:{"diseaseCode": vm.curDisease.diseaseCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.diseaseLGroups = result.data.diseaseLGroups;
										vm.diseaseSGroups = result.data.diseaseSGroups;
									}else{
										alert("组合获取失败！");
									}
								},
								error:function(){
									alert("组合获取失败！");
								}
							});
							vm.dialogVisible = false;
						}else{
							alert("解析失败！");
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
			},
			handleAdd:function(type){
				this.addGroupContent = '';
				this.curGroup = {};
				var addGroup = {
					groupType:type,
					complaintCode:this.curComplaint.complaintCode,
					diseaseCode:this.curDisease.diseaseCode
				};
				this.curGroup = addGroup;
				this.addDialog =true;
			},
			confirmAddGroup:function(){
				var addGroupContent = this.addGroupContent;
				var vm = this;
				if (addGroupContent=="") {
					alert("组合内容不能为空");
					return;
				}
				if (addGroupContent.charAt(addGroupContent.length-1)!=',') {
					alert("不符合规范，末尾请加入英文逗号");
					return;
				}
				//过滤中文逗号
				 addGroupContent = addGroupContent.replace(new RegExp('，',"gm"),',');
				 $.ajax({
					type:"post",
					url:CONST.url+"addGroup",
					data:{
						groupContent: addGroupContent,
						groupType: vm.curGroup.groupType,
						complaintCode: vm.curGroup.complaintCode,
						diseaseCode: vm.curGroup.diseaseCode
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							vm.addDialog = false;
							$.ajax({
								type:"post",
								url:CONST.url+"queryByDisease",
								data:{"diseaseCode": vm.curDisease.diseaseCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.diseaseLGroups = result.data.diseaseLGroups;
										vm.diseaseSGroups = result.data.diseaseSGroups;
									}else{
										alert(result.msg);
									}
								},
								error:function(){
									alert("组合获取失败！");
								}
							});
							vm.dialogVisible = false;
						}else{
							alert(result.msg);
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
			},
			symptomEdit:function(index,row){
				this.curSymptom = row;
				this.editSymptomDialog = true;
				this.newSymptomName = row.symptomName;
			},
			confirmEditSymptom:function(){
				//内容检查
				if (this.newSymptomName == '') {
					alert("内容不可为空");
				}
				//发送到后台，更新数据
				//重新加载数据
				var vm = this;
				$.ajax({
					type:"post",
					url:CONST.url+"updateSymptomById",
					data:{
						"symptomName": vm.newSymptomName,
						"symptomId": vm.curSymptom.symptomId
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							$.ajax({
								type:"get",
								url:CONST.url+"getComplaintByCode",
								data:{"complaintCode": vm.curComplaint.complaintCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.allSymptoms = result.data.symptomList;
									}else{
										alert(result.msg);
									}
								},
								error:function(){
									alert("请求失败！");
								}
							});
							vm.editSymptomDialog = false;
						}else{
							alert("解析失败！");
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
			},
			symptomAdd:function(){
				this.addSymptomName = '';
				this.addSymptomCode ='';
				this.addSymptomDialog = true;
			},
			confirmAddSymptom:function(){
				if (this.addSymptomName==''||this.addSymptomCode=='') {
					alert("Sorry，信息不全，不予通过");
					return;
				}
				var vm = this;
				$.ajax({
					type:"post",
					url:CONST.url+"addSymptom",
					data:{
						"symptomName": vm.addSymptomName,
						"symptomCode": vm.addSymptomCode,
						"complaintCode": vm.curComplaint.complaintCode
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							$.ajax({
								type:"get",
								url:CONST.url+"getComplaintByCode",
								data:{"complaintCode": vm.curComplaint.complaintCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.allSymptoms = result.data.symptomList;
									}else{
										alert(result.msg);
									}
								},
								error:function(){
									alert("请求失败！");
								}
							});
							vm.addSymptomDialog = false;
						}else{
							alert("失败："+result.msg);
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
			},
			symptomDelete:function(index,row){
				var vm = this;
				 this.$confirm('建议点击【取消】后使用编辑功能备注删除，若仍坚持删除，请点击【确定】')
		          .then(_ => {
		            //执行删除功能
		            $.ajax({
					type:"post",
					url:CONST.url+"deleteSymptomById",
					data:{
						"symptomId": row.symptomId
					},
					success:function(result){
						if (result.code==0||result.code=='0') {
							//更新后刷新列表
							$.ajax({
								type:"get",
								url:CONST.url+"getComplaintByCode",
								data:{"complaintCode": vm.curComplaint.complaintCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.allSymptoms = result.data.symptomList;
									}else{
										alert(result.msg);
									}
								},
								error:function(){
									alert("请求失败！");
								}
							});
						}else{
							alert("解析失败！");
						}
					},
					error:function(){
						alert("解析失败！");
					}
				});
		          })
		          .catch(_ => {});
			},
			symptomUp:function(index,row){
				//如果是第一个，不处理
				var allSymptoms = this.allSymptoms;
				if (index == 0) {
					return;
				}
				for (var i = 1; i < allSymptoms.length; i++) {
					if (row.symptomId == allSymptoms[i].symptomId) {
						var symptom = allSymptoms[i];
						allSymptoms[i] = allSymptoms[i-1];
						allSymptoms[i-1] = symptom;
						break;
					}
				}
				var symptomIds="";
				allSymptoms.forEach(function(symptom){
					symptomIds += symptom.symptomId+",";
				});
				console.log("排序后"+symptomIds);
				this.updateSymptomRank(symptomIds);
			},
			symptomDown:function(index,row){
				//如果是最后一个，不处理
				var allSymptoms = this.allSymptoms;
				if (index+1 == allSymptoms.length) {
					return;
				}
				
				for (var i = 0; i < allSymptoms.length-1; i++) {
					if (row.symptomId == allSymptoms[i].symptomId) {
						var symptom = allSymptoms[i];
						allSymptoms[i] = allSymptoms[i+1];
						allSymptoms[i+1] = symptom;
						break;
					}
				}
				var symptomIds="";
				allSymptoms.forEach(function(symptom){
					symptomIds += symptom.symptomId+",";
				});
				console.log("排序后"+symptomIds);
				this.updateSymptomRank(symptomIds);
			},
			updateSymptomRank:function(symptomIds){
				var vm =this;
				$.ajax({
                    type:"post",
                    url:CONST.url+"updateSymptomRank",
                    data:{"symptomIds": symptomIds},
                    success:function(result){
                        if (result.code==0||result.code=='0') {
                        	//更新成功，再次加载
                        	$.ajax({
								type:"get",
								url:CONST.url+"getComplaintByCode",
								data:{"complaintCode": vm.curComplaint.complaintCode},
								success:function(result){
									if (result.code==0||result.code=='0') {
										vm.allSymptoms = result.data.symptomList;
									}else{
										alert(result.msg);
									}
								},
								error:function(){
									alert("请求失败！");
								}
							});
                        }else{
                        	alert("失败："+result.msg);
                        }
                    },
                    error:function(){
                    	alert("请求失败！");
                    }
                });
			},
			diseaseAdd:function(){

			},
			confirmEditDisease:function(){
				//判断一下内容
				if (this.newDiseaseName==''||this.newDiseaseDisposalCodes=='') {
					alert("都不可为空");
				}
				var vm =this;
				$.ajax({
                    type:"post",
                    url:CONST.url+"updateDisease",
                    data:{
                    	"diseaseId": vm.curDisease.diseaseId,
                    	"diseaseName":vm.newDiseaseName,
                    	"diseaseDisposalCodes":vm.newDiseaseDisposalCodes
                    },
                    success:function(result){
                        if (result.code==0||result.code=='0') {
                        	//更新成功，再次加载
                        	$.ajax({
			                    type:"get",
			                    url:CONST.url+"getDiseaseByComplaint",
			                    data:{"complaintCode": vm.curComplaint.complaintCode},
			                    success:function(result){
			                        if (result.code==0||result.code=='0') {
			                        	vm.diseases = result.data;
			                        	vm.editDiseaseDialog = false;
			                        }else{
			                        	alert("主诉数据请求失败！");
			                        }
			                    },
			                    error:function(){
			                    	alert("主诉数据请求失败！");
			                    }
			                });
                        }else{
                        	alert("失败："+result.msg);
                        }
                    },
                    error:function(){
                    	alert("请求失败！");
                    }
                });
			},
			confirmAddDisease:function(){

			},
			diseaseEdit:function(index,row){
				this.curDisease = row;
				this.editDiseaseDialog = true;
				this.newDiseaseName = row.diseaseName;
				this.newDiseaseDisposalCodes = row.diseaseDisposalCodes;
			},
			diseaseJieXi:function(index,row){
				this.curDisease = row;
				var vm =this;
				$.ajax({
                    type:"get",
                    url:CONST.url+"analyDisposals",
                    data:{
                    	"diseaseCode": row.diseaseCode
                    },
                    success:function(result){
                        if (result.code==0||result.code=='0') {
                        	vm.disposals = result.data;  	
                        }else{
                        	alert("处置数据请求失败！");
                        }
                    },
                    error:function(){
                    	alert("处置数据请求失败！");
                    }
                })
			}

		},
		mounted(){
            this.$nextTick(()=>{
                var that=this;
                $.ajax({
                    type:"get",
                    url:CONST.url+"getSystemInfo",
                    success:function(result){
                        if (result.code==0||result.code=='0') {
                        	that.systems = result.data
                        }else{
                        	alert("主诉数据请求失败！");
                        }
                    },
                    error:function(){
                    	alert("主诉数据请求失败！");
                    }
                });
            })
        }
	}
</script>
<style type="text/css" scoped>
	.keyWords{
		font-weight: bolder;
		color: orange;
	}
	.el-row{
		line-height: 35px;
	}
	.panel{
		border: 1px solid #cccccc;
	}
	.jiexiPanel{
		margin-left: 30px;
	}
	.longPanel{
		margin-top: 30px;
		margin-bottom: 30px;
	}
	.symptomPanel{
		margin-top: 30px;
	}
</style>